<?php

defined('RUN') or die('No access');
class Session
{
    public static function start()
    {
        session_start();
    }
    public static function createNewId()
    {
        session_regenerate_id();
    }
    public static function set($a, $b, $c = true)
    {
        if (!self::has($a) || $c)
        {
            $_SESSION[$a] = $b;
            return true;
        }
        return false;
    }
    public static function unsets($a)
    {
        unset($_SESSION[$a]);
    }
    public static function has($a)
    {
        return array_key_exists($a, $_SESSION);
    }
    public static function get($a)
    {
        if (self::has($a))
        {
            return $_SESSION[$a];
        }
        return null;
    }
    public static function setFlash($a, $b)
    {
        $_SESSION['svdm_flash']['new'][$a] = $b;
        return true;
    }
    public static function getFlash($a)
    {
        if (isset($_SESSION['svdm_flash']['old'][$a]))
        {
            return $_SESSION['svdm_flash']['old'][$a];
        }
        return null;
    }
    public static function transferFlash()
    {
        if (isset($_SESSION['svdm_flash']['new']))
        {
            $d = $_SESSION['svdm_flash']['new'];
            unset($_SESSION['svdm_flash']['new']);
            $_SESSION['svdm_flash']['old'] = $d;
            return true;
        }
        unset($_SESSION['svdm_flash']['old']);
        return false;
    }
    public static function destroy()
    {
        session_destroy();
    }
}
